{% extends "shuup/front/base.jinja" %}
{% from "shuup/simple_cms/macros.jinja" import render_open_graph with context %}

{% block title %}{{ page.title }}{% endblock %}

{% block content_title %}
    {% if page.render_title %}
        {{ page.title }}
    {% endif %}
{% endblock %}

{% block extrameta %}
{{ render_open_graph(page) }}
{% endblock %}

{% block breadcrumb %}
    <ol class="breadcrumb">
        <li><a href="/">{% trans %}Home{% endtrans %}</a></li>
        {% for ancestor in page.get_ancestors() if ancestor.is_visible() %}
            <li><a href="{{ url('shuup:cms_page', url=ancestor.url) }}">{{ ancestor.title }}</a></li>
        {% endfor %}
        <li class="active">{{ page.title }}</li>
    </ol>
{% endblock %}
{% block content %}
    {{ page.get_html()|safe }}
    {% if page.list_children_on_page %}
        {# TODO: add pagination for children list #}
        {% for child in page.children.visible(request.shop, user=request.user).order_by("-available_from") %}
            <div class="row">
                <a href="{{ url('shuup:cms_page', url=child.url) }}"><h2>{{ child.title }}</h2></a>
                {% if child.available_from and page.show_child_timestamps %}
                    <small>{{ child.available_from|datetime }}</small>
                {% endif %}
                <p>{{ child.get_html()|safe|striptags|truncate(256) }}</p>
            </div>
        {% endfor %}
    {% endif %}
    {% placeholder "cms_page" %}{% endplaceholder %}
{% endblock %}
